#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/errno.h>
#include <cpu.h>
#include <interrupts.h>
#include <spinlock.h>
#include <console.h>
#include <fences.h>
#include <wfi.h>


extern int main(void);

void _init(void)
{
    int ret;

    /**
     * These initializations must be executed first and in fixed order.
     */
    interrupts_init();
    cpu_init();

    if(cpu_is_master()){ 
        console_init();
        ret = main();
    } else {
        /* The secondarys boot into idle state */
        cpu_idle();
    }

    /* This point should never be reached */
    exit(ret);
}
